Add upgrade e2e test and fix PackageUpgradedEvent parsing#456
Open
Add upgrade e2e test and fix PackageUpgradedEvent parsing#456
Conversation
2dc5423 to
0403601
Compare
bmwill
reviewed
Apr 15, 2026
bmwill
reviewed
Apr 15, 2026
bmwill
reviewed
Apr 15, 2026
bmwill
reviewed
Apr 15, 2026
bmwill
reviewed
Apr 15, 2026
bmwill
reviewed
Apr 15, 2026
42de78f to
b2b4f6d
Compare
Adds an end-to-end test that exercises the full governance-gated upgrade lifecycle and verifies cascading effects across the stack. The test found a real bug: PackageUpgradedEvent was missing from HashiEvent::try_parse(), so validators never learned about package upgrades via the event stream. Fixed by adding the missing match arm. Test flow: - Deposit before upgrade, verify balance survives (state continuity) - Upgrade via propose/vote/execute+publish+finalize - Verify all node watchers pick up the new package version - Deposit after upgrade through full validator confirmation path - Call v2-only canary module (new code reachable) - Disable v1, verify entry points rejected
Most of upgrade_flow.rs was either generic proposal-flow plumbing or
upgrade-specific PTB construction — neither of which needs to live in
the test crate. Pulls the non-test pieces into the hashi crate so both
the e2e harness and the CLI can share them.
New `hashi::cli::upgrade` module with:
- build_upgrade_package — wraps `sui move build --dump-bytecode-as-base64`
and parses the output into a Publish + digest.
- build_upgrade_execution_transaction — constructs the
`execute + publish + finalize` PTB the upgrade proposal requires.
- build_execute_proposal_transaction — generic non-upgrade proposal
execution; takes execute_package_id separately so post-upgrade
disable_version still routes through the new package.
- extract_proposal_id_from_response — parse ProposalCreatedEvent.
- extract_new_package_id_from_response — find the new package in the
upgrade tx effects.
In `hashi::cli::client`:
- Replace the UpdateConfig-specific build_vote_update_config_transaction
/ build_execute_update_config_transaction with a generic standalone
build_vote_transaction. HashiClient::build_vote_transaction now
delegates to it, removing the duplicate PTB construction.
The e2e `upgrade_flow.rs` and the TestNetworksBuilder on-chain config
override flow now go through these helpers, which drops ~300 lines of
duplicated PTB boilerplate and inline event parsing.
No behaviour change; no new CLI commands are wired up yet. Follow-up
work on the cli-governance-improvements branch will add pre-flight
checks (version +1 enforcement, quorum readiness, etc.) and an
execute-upgrade CLI command that uses these helpers.
cdfb5b6 to
f6a8afd
Compare
Contributor
Author
|
@bmwill this is ready for another round! |
This was referenced Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PackageUpgradedEventwas missing fromHashiEvent::try_parse(), so validators never learned about package upgrades via the event stream — only on full rescrapeBug fix
PackageUpgradedEventhad a struct definition,MoveTypeimpl, and was handled in the watcher's event loop (watcher.rs:228), but was never added to thetry_parse()match arms inmove_types/mod.rs. The event was silently dropped at the catch-all_ => return Ok(None). After an upgrade, validators would not update their package version map until a subscription reconnect triggered a full rescrape.Test details
The test programmatically patches the deployed package at test time (bumps
PACKAGE_VERSION, injects a canary module), then verifies:PackageUpgradedEventOnchainState.package_id()returns the new package on all nodesEVersionDisabledFiles changed
crates/hashi-types/src/move_types/mod.rs— addPackageUpgradedEventtotry_parse()crates/e2e-tests/src/upgrade_flow.rs— upgrade helpers (prepare, build, propose/vote/execute, disable)crates/e2e-tests/src/upgrade_tests.rs— the e2e testcrates/e2e-tests/src/lib.rs— module declarations +dir()accessorTest plan
cargo test -p e2e-tests -- test_upgrade_v1_to_v2 --ignored— passes in ~44scargo check -p hashi— compiles clean